//
//  VisitorView.swift
//  JMWB
//
//  Created by 个人电脑 on 16/3/14.
//  Copyright © 2016年 个人电脑. All rights reserved.
//

import UIKit

class VisitorView: UIView {

    class func visitorView() -> VisitorView {
        return NSBundle.mainBundle().loadNibNamed("VisitorView", owner: nil, options: nil).first as! VisitorView
    }
    
    @IBOutlet weak var iconImage: UIImageView!
    @IBOutlet weak var rotationImage: UIImageView!
    @IBOutlet weak var tipLable: UILabel!
    @IBOutlet weak var registerBtn: UIButton!
    @IBOutlet weak var loginBtn: UIButton!
    
    func setVisitorViewInfo(iconName : String, tipString : String){
    
        iconImage.image = UIImage(named: iconName)
        tipLable.text = tipString
        rotationImage.hidden = true
    }
    
    func addRotationAnimate(){
    
        let rotationAnimate = CABasicAnimation(keyPath: "transform.rotation.z")
        //起点
        rotationAnimate.fromValue = 0
        //终点
        rotationAnimate.toValue = M_PI * 2
        //动画时间
        rotationAnimate.duration = 10
        //执行次数
        rotationAnimate.repeatCount = MAXFLOAT
        // 将该属性设置成false,那么view消失时(切换View时),动画不会被移除
        rotationAnimate.removedOnCompletion = false
        //将动画添加到图层
        rotationImage.layer.addAnimation(rotationAnimate, forKey: nil)
        
    }
}
